package com.stox.ui.javafx.core.perspective;

import javafx.scene.control.ChoiceBox;
import javafx.util.StringConverter;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.stox.dto.Perspective;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PerspectiveChoiceBox extends ChoiceBox<Perspective> {

	public PerspectiveChoiceBox() {
		Perspective perspective = new Perspective();
		perspective.setId(1l);
		perspective.setName("Default Perspective");
		getItems().add(perspective);
		getSelectionModel().select(0);
		
		setConverter(new StringConverter<Perspective>(){
			@Override
			public Perspective fromString(String arg0) {
				return null;
			}
			
			@Override
			public String toString(Perspective perspective) {
				return perspective.getName();
			}
		});
	}
	
}
